package ltd.bugs.cute.common.util;

import org.reflections.util.Utils;

/**
 * 类名精简处理的工具类
 * 
 * @author zhengzhq
 *
 */
public class ClassNameUtil {

  private static final String CLASSNAME_SHORT_REG_PATTERN = "(\\w)(\\w{0,}\\.)";

  public static String getShortName(String classname) {
    if (Utils.isEmpty(classname)) {
      return "";
    }

    return classname.replaceAll(CLASSNAME_SHORT_REG_PATTERN, "$1.");
  }

  public static String getShortName(Class<?> classz) {
    return getShortName(classz.getName());
  }
}
